package com.cc.blog.web.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * RestTemplate
 * @Author cc
 * @Date 2025/1/13 16:55
 */
@Configuration
public class RestTemplateConfig {

    @Bean
    public RestTemplate restTemplate() {
        SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
        // 连接超时时间：5秒
        factory.setConnectTimeout(5000);
        // 读取超时时间：5秒
        factory.setReadTimeout(5000);
        return new RestTemplate(factory);
    }

}
